"""
Utility for creating php_tokens.py.
Data from http://php.net/manual/en/tokens.php
NOTE: <NOT SHOWN> means the non-ASCII character '\xc2'.
"""
lookup = [
    ('T_ABSTRACT',r'abstract',r'Class Abstraction (available since PHP 5.0.0)'),
    ('T_AND_EQUAL',r'&=',r'assignment operators'),
    ('T_ARRAY',r'array()',r'array(), array syntax'),
    ('T_ARRAY_CAST',r'(array)',r'type-casting'),
    ('T_AS',r'as',r'foreach'),
    ('T_BAD_CHARACTER',r'<NOT SHOWN>',r'anything below ASCII 32 except \\t (0x09), \\n (0x0a) and \\r (0x0d)'),
    ('T_BOOLEAN_AND',r'&&',r'logical operators'),
    ('T_BOOLEAN_OR',r'||',r'logical operators'),
    ('T_BOOL_CAST',r'(bool) or (boolean)',r'type-casting'),
    ('T_BREAK',r'break',r'break'),
    ('T_CASE',r'case',r'switch'),
    ('T_CATCH',r'catch',r'Exceptions (available since PHP 5.0.0)'),
    ('T_CHARACTER',r'<NOT SHOWN>',r'not used anymore'),
    ('T_CLASS',r'class',r'classes and objects'),
    ('T_CLASS_C',r'__CLASS__',r'magic constants (available since PHP 4.3.0) '),
    ('T_CLONE',r'clone',r'classes and objects (available since PHP 5.0.0) '),
    ('T_CLOSE_TAG',r'?> or %>',r'escaping from HTML'),
    ('T_COMMENT',r'// or #, and /* */ in PHP 5',r'comments'),
    ('T_CONCAT_EQUAL',r'.=',r'assignment operators'),
    ('T_CONST',r'const',r'class constants'),
    ('T_CONSTANT_ENCAPSED_STRING',r'''"foo" or 'bar''',r'string syntax'),
    ('T_CONTINUE',r'continue',r'continue'),
    ('T_CURLY_OPEN',r'{$',r'complex variable parsed syntax'),
    ('T_DEC',r'--',r'incrementing/decrementing operators'),
    ('T_DECLARE',r'declare',r'declare'),
    ('T_DEFAULT',r'default',r'switch'),
    ('T_DIR',r'__DIR__',r'magic constants (available since PHP 5.3.0)'),
    ('T_DIV_EQUAL',r'/=',r'assignment operators'),
    ('T_DNUMBER',r'0.12, etc',r'floating point numbers'),
    ('T_DOC_COMMENT',r'/** */',r'PHPDoc style comments (available since PHP 5.0.0) '),
    ('T_DO',r'do',r'do..while'),
    ('T_DOLLAR_OPEN_CURLY_BRACES',r'${',r'complex variable parsed syntax'),
    ('T_DOUBLE_ARROW',r'=>', 'array syntax'),
    ('T_DOUBLE_CAST',r'(real), (double) or (float)',r'type-casting'),
    ('T_DOUBLE_COLON',r'::',r'see T_PAAMAYIM_NEKUDOTAYIM below'),
    ('T_ECHO',r'echo',r'echo()'),
    ('T_ELSE',r'else',r'else'),
    ('T_ELSEIF',r'elseif',r'elseif'),
    ('T_EMPTY',r'empty',r'empty()'),
    ('T_ENCAPSED_AND_WHITESPACE',r'" $a"',r'constant part of string with variables'),
    ('T_ENDDECLARE',r'enddeclare',r'declare, alternative syntax'),
    ('T_ENDFOR',r'endfor',r'for, alternative syntax'),
    ('T_ENDFOREACH',r'endforeach',r'foreach, alternative syntax'),
    ('T_ENDIF',r'endif',r'if, alternative syntax'),
    ('T_ENDSWITCH',r'endswitch',r'switch, alternative syntax'),
    ('T_ENDWHILE',r'endwhile',r'while, alternative syntax'),
    ('T_END_HEREDOC',r'<NOT SHOWN>',r'heredoc syntax'),
    ('T_EVAL',r'eval()',r'eval()'),
    ('T_EXIT',r'exit or die',r'exit(), die()'),
    ('T_EXTENDS',r'extends',r'extends, classes and objects'),
    ('T_FILE',r'__FILE__',r'magic constants'),
    ('T_FINAL',r'final',r'Final Keyword (available since PHP 5.0.0)'),
    ('T_FOR',r'for',r'for'),
    ('T_FOREACH',r'foreach',r'foreach'),
    ('T_FUNCTION',r'function or cfunction',r'functions'),
    ('T_FUNC_C',r'__FUNCTION__',r'magic constants (available since PHP 4.3.0) '),
    ('T_GLOBAL',r'global',r'variable scope'),
    ('T_GOTO',r'goto',r'(available since PHP 5.3.0)'),
    ('T_HALT_COMPILER',r'__halt_compiler()',r'__halt_compiler (available since PHP 5.1.0)'),
    ('T_IF',r'if',r'if'),
    ('T_IMPLEMENTS',r'implements',r'Object Interfaces (available since PHP 5.0.0)'),
    ('T_INC',r'++',r'incrementing/decrementing operators'),
    ('T_INCLUDE',r'include()',r'include()'),
    ('T_INCLUDE_ONCE',r'include_once()',r'include_once()'),
    ('T_INLINE_HTML',r'<NOT SHOWN>',r'text outside PHP'),
    ('T_INSTANCEOF',r'instanceof',r'type operators (available since PHP 5.0.0) '),
    ('T_INT_CAST',r'(int) or (integer)',r'type-casting'),
    ('T_INTERFACE',r'interface',r'Object Interfaces (available since PHP 5.0.0)'),
    ('T_ISSET',r'isset()',r'isset()'),
    ('T_IS_EQUAL',r'==',r'comparison operators'),
    ('T_IS_GREATER_OR_EQUAL',r'>=',r'comparison operators'),
    ('T_IS_IDENTICAL',r'===',r'comparison operators'),
    ('T_IS_NOT_EQUAL',r'!= or <>',r'comparison operators'),
    ('T_IS_NOT_IDENTICAL',r'!==',r'comparison operators'),
    ('T_IS_SMALLER_OR_EQUAL',r'<=',r'comparison operators'),
    ('T_LINE',r'__LINE__',r'magic constants'),
    ('T_LIST',r'list()',r'list()'),
    ('T_LNUMBER',r'123, 012, 0x1ac, etc',r'integers'),
    ('T_LOGICAL_AND',r'and',r'logical operators'),
    ('T_LOGICAL_OR',r'or',r'logical operators'),
    ('T_LOGICAL_XOR',r'xor',r'logical operators'),
    ('T_METHOD_C',r'__METHOD__',r'magic constants (available since PHP 5.0.0) '),
    ('T_MINUS_EQUAL',r'-=',r'assignment operators'),
    ('T_ML_COMMENT',r'/* and */',r'comments (PHP 4 only)'),
    ('T_MOD_EQUAL',r'%=',r'assignment operators'),
    ('T_MUL_EQUAL',r'*=',r'assignment operators'),
    ('T_NAMESPACE',r'namespace',r'namespaces (available since PHP 5.3.0) '),
    ('T_NS_C',r'__NAMESPACE__',r'namespaces (available since PHP 5.3.0) '),
    ('T_NS_SEPARATOR',r'\\',r'namespaces (available since PHP 5.3.0) '),
    ('T_NEW',r'new',r'classes and objects'),
    ('T_NUM_STRING',r'"$a[0]"',r'numeric array index inside string'),
    ('T_OBJECT_CAST',r'(object)',r'type-casting'),
    ('T_OBJECT_OPERATOR',r'->',r'classes and objects'),
    ('T_OLD_FUNCTION',r'old_function',r'(PHP 4 Only)'),
    ('T_OPEN_TAG',r'<?php, <? or <%',r'escaping from HTML'),
    ('T_OPEN_TAG_WITH_ECHO',r'<?= or <%=',r'escaping from HTML'),
    ('T_OR_EQUAL',r'|=',r'assignment operators'),
    ('T_PAAMAYIM_NEKUDOTAYIM',r'::',r'::. Also defined as T_DOUBLE_COLON.'),
    ('T_PLUS_EQUAL',r'+=',r'assignment operators'),
    ('T_PRINT',r'print()',r'print()'),
    ('T_PRIVATE',r'private',r'classes and objects (available since PHP 5.0.0) '),
    ('T_PUBLIC',r'public',r'classes and objects (available since PHP 5.0.0) '),
    ('T_PROTECTED',r'protected',r'classes and objects (available since PHP 5.0.0) '),
    ('T_REQUIRE',r'require()',r'require()'),
    ('T_REQUIRE_ONCE',r'require_once()',r'require_once()'),
    ('T_RETURN',r'return',r'returning values'),
    ('T_SL',r'<<',r'bitwise operators'),
    ('T_SL_EQUAL',r'<<=',r'assignment operators'),
    ('T_SR',r'>>',r'bitwise operators'),
    ('T_SR_EQUAL',r'>>=',r'assignment operators'),
    ('T_START_HEREDOC',r'<<<',r'heredoc syntax'),
    ('T_STATIC',r'static',r'variable scope'),
    ('T_STRING',r'''"$a['a']"''',r'string array index inside string'),
    ('T_STRING_CAST',r'(string)',r'type-casting'),
    ('T_STRING_VARNAME',r'"${a',r'complex variable parsed syntax'),
    ('T_SWITCH',r'switch',r'switch'),
    ('T_THROW',r'throw',r'Exceptions (available since PHP 5.0.0)'),
    ('T_TRY',r'try',r'Exceptions (available since PHP 5.0.0)'),
    ('T_UNSET',r'unset()',r'unset()'),
    ('T_UNSET_CAST',r'(unset)',r'type-casting (available since PHP 5.0.0)'),
    ('T_USE',r'use',r'namespaces (available since PHP 5.3.0)'),
    ('T_VAR',r'var',r'classes and objects'),
    ('T_VARIABLE',r'$foo',r'variables'),
    ('T_WHILE',r'while',r'while, do..while'),
    ('T_WHITESPACE',r'\\t \\r\\n',r'<NOT SHOWN>'),
    ('T_XOR_EQUAL',r'^=',r'assignment operators'),
]

print '"""PHP entity constants for use in parsing code."""'
for item in lookup:
    print "%s = '''%s''' #%s" % item